package com.easipass.unifiedconfig;

import java.util.Collection;
import java.util.List;

import com.easipass.unifiedconfig.core.Authentication;

/**
 * 
 * @version $Id$
 * @author itea
 * @date 2010-1-28
 */
public interface Session {

	ConfigManager getConfigManager();
	
	Parameter getParameter(String uci) 
		throws MalformedUCIException, NotFoundException, InsufficientPrivillageException;
	
	Parameter getParameter(UCI uci) 
		throws NotFoundException, InsufficientPrivillageException;
	
	void setParameter(Parameter p)
		throws NotFoundException, InsufficientPrivillageException;
	
	void removeParameter(UCI uci)
		throws NotFoundException, InsufficientPrivillageException;
	
	void insertParameterValues(UCI uci, String... values)
	throws NotFoundException, InsufficientPrivillageException;
	
	void deleteParameterValues(UCI uci, String... values)
	throws NotFoundException, InsufficientPrivillageException;
	
	boolean existsParameter(UCI uci);
	
	Collection<UCI> listParameters(UCI range)
	throws NotFoundException;
	
	// ----
	/*
	void createAccount(UCI uci)
		throws NotFoundException, InsufficientPrivillageException;
	
	void createModule(UCI uci)
		throws NotFoundException, InsufficientPrivillageException;
	*/
	// ----

	boolean authenticate(String domain, String user, String password)
		throws NotFoundException;
	
	Collection<Authentication> getAuthentications();
	
	boolean createUser(String domain, String user, String password)
	throws NotFoundException, InsufficientPrivillageException;
	
	boolean changeUserPassword(String domain, String user, String newPassword)
	throws NotFoundException, InsufficientPrivillageException;
	
	boolean removeUser(String domain, String user)
	throws NotFoundException, InsufficientPrivillageException;
	
	boolean existsUser(String domain, String user)
	throws NotFoundException;
	
	List<String> listUsers(String domain)
	throws NotFoundException;
	
	// ----
	
	void grantModify(String domain, String user, UCI uci)
	throws NotFoundException, InsufficientPrivillageException;
	
	void revokeModify(String domain, String user, UCI uci)
	throws NotFoundException, InsufficientPrivillageException;
	
	void grantSys(String domain, String user, String pri)
	throws NotFoundException, InsufficientPrivillageException;
	
	void revokeSys(String domain, String user, String pri)
	throws NotFoundException, InsufficientPrivillageException;

	List<String> listModifyPrivillages(String domain, String user)
	throws NotFoundException, InsufficientPrivillageException;
	
	List<String> listSysPrivillages(String domain, String user)
	throws NotFoundException, InsufficientPrivillageException;
	
}
